const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('students.db');

db.serialize(() => {
    // 删除已存在的 students 表 (如果存在)
    db.run("DROP TABLE IF EXISTS students");

    // 创建 students 表，id 列为 AUTOINCREMENT
    db.run("CREATE TABLE students (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, age INTEGER, grade TEXT)");

    const stmt = db.prepare("INSERT INTO students (name, age, grade) VALUES (?, ?, ?)");
    for (let i = 1; i <= 1000; i++) {
        stmt.run(`Student ${i}`, Math.floor(Math.random() * 10) + 10, `${Math.floor(Math.random() * 6) + 1} 年级`);
    }
    stmt.finalize();
});

db.close();